package ru.sanluck.tg.command;

import org.telegram.telegrambots.meta.api.objects.User;
import ru.sanluck.tg.Dialog;
import ru.sanluck.tg.TgUser;
import ru.sanluck.tg.TgUserService;
import ru.sanluck.tg.UserMapper;

public abstract class AbsTgCommand implements TgCommand {
    protected TgUserService tgUserService;
    protected UserMapper userMapper;

    public AbsTgCommand(TgUserService tgUserService, UserMapper userMapper) {
        this.tgUserService = tgUserService;
        this.userMapper = userMapper;
    }

    protected TgUser createUser(User user, Dialog dialog) {
        TgUser tgUser = userMapper.toDomain(user);
        tgUser.setDialog(dialog);
        return tgUserService.createTgUser(tgUser);
    }
}
